<template>
    <div class="checkTel">
        <van-nav-bar title="注册" class="navbar" left-text="返回" left-arrow @click-left="onClickLeft" />
    <van-notice-bar left-icon="volume-o" text="牢记账号密码，不要随意泄露密码，请勿随意交易账号！" />
        <div class="content">
            <van-field v-model="tel" name="手机号" placeholder="手机号" />
            <div style="margin: 16px;">
                <van-button round block type="primary" :disabled="!flag" class="custom_btn" @click="checkPhone">
                    提交
                </van-button>
            </div>
            <router-link to="/Login">已有账号？去登录</router-link>
        </div>
    </div>
</template>

<script>
import { doCheckphone } from '@/apis/user';
import { showToast } from 'vant';
export default {
    data() {
        return {
            tel: '13334445556'
        }
    },
    computed: {
        flag() {
            return /^1[35789]\d{9}$/.test(this.tel)
        }
    },
    methods: {
        onClickLeft() {
            this.$router.back()
        }
    },
    methods: {
        onClickLeft() {
            this.$router.back()
        },
        checkPhone() {
            doCheckphone({ tel: this.tel }).then(res => {
                if (res.data.code == '10005') {
                    return showToast('手机号已被注册')
                }
                //200
                localStorage.setItem("tel", this.tel)
                this.$router.push("/register/msg")
            })
        }
    }
}
</script>

<style lang="less" scoped>
.custom_btn {
    background: linear-gradient(to right, red, orange);
}

.navbar {
    color: rebeccapurple;
}
</style>